<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="计划号" prop="docNum">
        <el-input
          v-model="queryParams.docNum"
          placeholder="请输入计划号模糊查询"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 240px"
        />
      </el-form-item>
      <el-form-item label="开始时间">
        <el-date-picker
          v-model="queryParams.dtDocStart"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="起始日期"
          end-placeholder="截止日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间">
        <el-date-picker
          v-model="queryParams.dtDocFinish"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="起始日期"
          end-placeholder="截止日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['mes:ps:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['mes:ps:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['mes:ps:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['mes:ps:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="psList" :highlight-current-row="true" @selection-change="handleSelectionChange" stripe>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="计划时间" align="center" prop="planDocDt" width="150"/>
      <el-table-column label="计划号" align="center" prop="docNum" width="150"/>
      <el-table-column label="物料名称" align="center" prop="itemName" width="180" :show-overflow-tooltip="true"/>
      <el-table-column label="物料编码" align="center" prop="itemNum" width="160"/>
      <el-table-column label="规格" align="center" prop="itemSpecification" width="120"/>
      <el-table-column label="数量" align="center" prop="psQty" />
      <el-table-column label="计量单位" align="center" prop="wmsDictMeasuringUnit">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_dict_measuring_unit" :value="scope.row.wmsDictMeasuringUnit"/>
        </template>
      </el-table-column>

      <el-table-column label="开始日期" align="center" prop="dtStart" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dtStart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束日期" align="center" prop="dtFinish" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dtFinish, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="任务号" align="center" prop="taskDocNum" width="150">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="show_task(scope.row)"
          >{{scope.row.taskDocNum}}<i class="el-icon-caret-right"></i>
          </el-button>
        </template>
      </el-table-column>

      <el-table-column label="车间" align="center" prop="deptName" width="120"/>

      <el-table-column label="经办人" align="center" prop="attentionUserName" width="120"/>
      <el-table-column label="审核状态" align="center" prop="oaDictConfirmStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.oa_dict_confirm_status" :value="scope.row.oaDictConfirmStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="已完成" align="center" prop="sysYesNoDone" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.sysYesNoDone"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['mes:ps:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['mes:ps:remove']"
          >删除</el-button>

          <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['com:dropdown:more']">
            <span class="el-dropdown-link">
              <i class="el-icon-d-arrow-right el-icon--right"></i>更多
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="handleDispatch" icon="el-icon-share"
                                v-hasPermi="['mes:ps: transmit']"
                                :disabled="scope.row.oaDictConfirmStatus !='pass'">下达</el-dropdown-item>
              <el-dropdown-item command="setDone" icon="el-icon-s-flag"
                                v-hasPermi="['com:single:done']">完成</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>




        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改生产计划对话框 -->
    <el-dialog v-dialogDrag v-dialogDragWidth :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form"  label-width="80px">
        <el-form-item label="订单明细ID" prop="fkOrderDetailUuid">
          <el-input v-model="form.fkOrderDetailUuid" placeholder="请输入订单明细ID" />
        </el-form-item>
        <el-form-item label="开始时间" prop="dtStart">
          <el-date-picker clearable size="small"
            v-model="form.dtStart"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="完成时间" prop="dtFinish">
          <el-date-picker clearable size="small"
            v-model="form.dtFinish"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择完成时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="数量" prop="psQty">
          <el-input v-model="form.psQty" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="计量单位" prop="wmsDictMeasuringUnit">
          <el-select v-model="form.wmsDictMeasuringUnit" placeholder="请选择计量单位">
            <el-option
              v-for="dict in dict.type.wms_dict_measuring_unit"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" prop="sysNormalDisable">
          <el-select v-model="form.sysNormalDisable" placeholder="请选择状态">
            <el-option
              v-for="dict in dict.type.sys_normal_disable"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单据编号" prop="docNum">
          <el-input v-model="form.docNum" placeholder="请输入单据编号" />
        </el-form-item>
        <el-form-item label="单据时间" prop="docDt">
          <el-date-picker clearable size="small"
            v-model="form.docDt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择单据时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="docNote">
          <el-input v-model="form.docNote" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="经办人ID" prop="fkAttentionUserId">
          <el-input v-model="form.fkAttentionUserId" placeholder="请输入经办人ID" />
        </el-form-item>
        <el-form-item label="审核人" prop="fkConfirmUserId">
          <el-input v-model="form.fkConfirmUserId" placeholder="请输入审核人" />
        </el-form-item>
        <el-form-item label="审核时间" prop="confirmDt">
          <el-date-picker clearable size="small"
            v-model="form.confirmDt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择审核时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核状态">
          <el-radio-group v-model="form.oaDictConfirmStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核意见" prop="confirmNote">
          <el-input v-model="form.confirmNote" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 车间计划下达生成派工单 -->
    <el-dialog v-dialogDrag v-dialogDragWidth :title="title_dispatch" :visible.sync="open_dispatch" width="800px" append-to-body :close-on-click-modal=false>
      <el-form ref="form_dispatch" :model="form_dispatch" label-width="90px" :rules="rules_dispatch">
        <el-col :span="24">
          <el-form-item label="车间计划" prop="fkMesPsUuid" v-show="false">
            <el-input v-model="form_dispatch.fkMesPsUuid"/>
          </el-form-item>
        </el-col>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单据编号" prop="docNum">
              <el-input v-model="form_dispatch.docNum" placeholder="请输入单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工段" prop="fkDeptId">
              <el-select
                filterable
                v-model="form_dispatch.fkDeptId"
                placeholder="请选择工段"
                clearable
                style="width: 300px">
                <el-option
                  v-for="item in deptList"
                  :key="item.fkDeptId"
                  :label="item.deptName"
                  :value="item.fkDeptId"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item prop="dispatchQty">
            <span slot="label">
                    数量
                   <el-tooltip content="计划投放数量" placement="top">
                    <i class="el-icon-question"></i>
                    </el-tooltip>
                  </span>
              <el-input-number v-model="form_dispatch.dispatchQty" placeholder="请输入数量" :style="{width: '100%'}"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经办人" prop="fkAttentionUserId">
              <el-input v-model="form_dispatch.fkAttentionUserId" v-show="false"/>
              <el-input placeholder="请选择经办人" v-model="form_dispatch.selectedAttentionUser" class="input-with-select">
                <el-button @click="showDialog_selectTaskAttentionUserName(form_dispatch)" :style="{width: '100%'}" slot="append"
                           icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="开始日期" prop="dtStart">
              <el-date-picker clearable
                              v-model="form_dispatch.dtStart"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择开始日期"
                              :style="{width: '100%'}">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束日期" prop="dtDone">
              <el-date-picker clearable
                              v-model="form_dispatch.dtDone"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择结束日期"
                              :style="{width: '100%'}">
              </el-date-picker>
            </el-form-item>
          </el-col>

        <el-col :span="12">
          <el-form-item label="下达时间" prop="docDt">
            <el-date-picker clearable
                            v-model="form_dispatch.docDt"
                            type="datetime"
                            format="yyyy-MM-dd HH:mm"
                            value-format="yyyy-MM-dd HH:mm"
                            placeholder="选择下达时间"
                            :style="{width: '100%'}">
            </el-date-picker>
          </el-form-item>
        </el-col>

          <el-col :span="12">
            <el-form-item label="废品单" prop="fkWasteUuid">
              <el-input v-model="form_dispatch.fkWasteUuid" v-show="false"/>
              <el-input placeholder="请选择废品单" v-model="form_dispatch.wasteForm" class="input-with-select">
                <el-button @click="showDialog_selectWasteForm" slot="append"
                           icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
      </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="docNote">
              <el-input v-model="form_dispatch.docNote" placeholder="请输入备注" :style="{width: '100%'}" type="textarea"
                        autosize maxlength="50"
                        show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm_dispatch">确 定</el-button>
        <el-button @click="cancel_dispatch()">取 消</el-button>
      </div>
    </el-dialog>
    <select-user ref="component_selectAttentionUser" @ok="selectAttentionUser_done" />
    <select-waste ref="component_selectWasteForm" @ok="selectWaste_done"/>
  </div>
</template>

<script>
import { listPs, getPs, delPs, addPs, updatePs } from "@/api/mes/ps";
import {  addDispatch  } from "@/api/mes/dispatch";
import {newDocNum} from "@/api/oa/docNum";
import {listDeptGroup} from "@/api/comn/deptGroup";
import selectUser from "../../comn/userGroup/selectUser";
import { parseTime } from '@/utils/ruoyi'
import selectWaste from "../../qms/waste/selectWaste";
export default {
  name: "Ps",
  dicts: ['wms_dict_measuring_unit', 'sys_normal_disable','oa_dict_confirm_status','sys_yes_no'],
  components: { selectUser,selectWaste},
  data() {

    let validateDtStart = (rule, value, callback) => {
      if (!value) {
        callback(new Error("开始日期不能为空"));
      } else {
        // 如果结束日期没选
        if (!this.form_dispatch.dtDone) {
          callback();
        } else {
          // 结束日期有进行判断
          if (this.compareDate(value, this.form_dispatch.dtDone)) {
            // 如果开始日期在结束日期之前
            callback();
          } else {
            callback(new Error("开始日期不能再结束日期之后，请重新选择"));
          }
        }
      }
    };
    let validateDtEnd = (rule, value, callback) => {
      if (!value) {
        callback(new Error("结束日期不能为空"));
      } else {
        if (!this.form_dispatch.dtStart) {
          callback();
        } else {
          // 开始日期有
          if (this.compareDate(this.form_dispatch.dtStart, value)) {
            callback();
          } else {
            callback(new Error("结束日期不能在开始日期前，请重新选择"));
          }
        }
      }
    };
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产计划表格数据
      psList: [],
      deptList: [],
      // 弹出层标题
      title: "",
      title_dispatch: "",
      // 是否显示弹出层
      open: false,
      open_dispatch: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fkOrderDetailUuid: null,
        dtStart: null,
        dtFinish: null,
        psQty: null,
        wmsDictMeasuringUnit: null,
        sysNormalDisable: null,
        docTitle: null,
        docNum: null,
        docDt: null,
        docNote: null,
        fkAttentionUserId: null,
        fkConfirmUserId: null,
        confirmDt: null,
        oaDictConfirmStatus: null,
        confirmNote: null,
      },
      // 表单参数
      form: {},
      form_dispatch: {},
      // 表单校验
      rules_dispatch: {
        fkDeptId: [
          { required: true, message: "工段不能为空", trigger: "change" }
        ],
        dtStart: [
          {
            trigger: ["change"],
            validator: validateDtStart,
          },
        ],
        dtDone: [
          {
            trigger: ["change"],
            validator: validateDtEnd,
          },
        ],
        dispatchQty: [
          { required: true, message: "数量不能为空", trigger: "change" }
        ],
        docNum: [
          { required: true, message: "单据编号不能为空", trigger: "change" }
        ],
        docDt: [
          { required: true, message: "下达时间不能为空", trigger: "change" }
        ],
        fkAttentionUserId: [
          { required: true, message: "经办人不能为空", trigger: "change" }
        ],


      }
    };
  },
  created() {

    // $route params
    let mpsDocNum = this.$route.params && this.$route.params.mpsDocNum;
    if (mpsDocNum) {
      this.queryParams.docNum = mpsDocNum
    }else console.log('！！！ 无参数 ！！！')


    this.getList();
    this.getList_dept()
  },
  methods: {
    // 比较两个日期
    compareDate(start, end) {
      return new Date(end).getTime() >= new Date(start).getTime();
    },
    /** 查询生产计划列表 */
    getList() {
      this.loading = true;
      if (this.queryParams.dtDocStart) {
        this.queryParams.dtDocStartBegin = this.queryParams.dtDocStart[0]
        this.queryParams.dtDocStartEnd = this.queryParams.dtDocStart[1]
      } else {
        this.queryParams.dtDocStartBegin = null
        this.queryParams.dtDocStartEnd = null
      }
      if (this.queryParams.dtDocFinish) {
        this.queryParams.dtDocFinishBegin = this.queryParams.dtDocFinish[0]
        this.queryParams.dtDocFinishEnd = this.queryParams.dtDocFinish[1]
      } else {
        this.queryParams.dtDocFinishBegin = null
        this.queryParams.dtDocFinishEnd = null
      }
      listPs(this.queryParams).then(response => {
        this.psList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 列表: 部门（车间） */
    getList_dept() {
      listDeptGroup({comnDictDeptGroup: 'work_section'}).then(response => {
        this.deptList = response.rows;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancel_dispatch() {
      this.open_dispatch = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        mesPsUuid: null,
        fkOrderDetailUuid: null,
        dtStart: null,
        dtFinish: null,
        psQty: null,
        wmsDictMeasuringUnit: null,
        sysNormalDisable: null,
        docTitle: null,
        docNum: null,
        docDt: null,
        docNote: null,
        fkAttentionUserId: null,
        fkConfirmUserId: null,
        confirmDt: null,
        oaDictConfirmStatus: "0",
        confirmNote: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    reset_dispatch() {
      this.form_dispatch = {
        docNum: null,
        fkMesPsUuid: null,
        dtStart: null,
        dtDone: null,
        fkDeptId: null,
        wasteForm: null,
        fkWasteUuid: null,
        fkAttentionUserId: null,
        selectedAttentionUser: null,
        docDt: parseTime(Date.now(), '{y}-{m}-{d} {h}:{i}'),
      };
      this.resetForm("form_dispatch");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.mesPsUuid)
      this.docDts = selection.map(item => item.docDt)
      this.docNums = selection.map(item => item.docNum)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      // this.reset();
      // this.open = true;
      // this.title = "添加生产计划";
      this.$msgbox("新增功能待实现,目前车间计划由车间任务审核通过后生成！")
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      // this.reset();
      // const mesPsUuid = row.mesPsUuid || this.ids
      // getPs(mesPsUuid).then(response => {
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "修改生产计划";
      // });
      this.$msgbox("修改功能待实现,目前车间计划由车间任务审核通过后生成！")
    },
    /** 下达按钮操作 */
    handleDispatch(row) {
      this.reset_dispatch()
      console.log(row)
      this.form_dispatch.fkMesPsUuid = row.mesPsUuid
      this.form_dispatch.psDocNum = row.docNum
      this.form_dispatch.dispatchQty = row.psQty
      newDocNum({preCode: 'DIS-', len: 12}).then(response => {
        this.form_dispatch.docNum = response.msg
      })
      this.open_dispatch = true;
      this.title_dispatch = "车间计划下达（新增派工单）";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.mesPsUuid != null) {
            updatePs(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPs(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 提交按钮 */
    submitForm_dispatch() {
      this.$refs["form_dispatch"].validate(valid => {
        if (valid) {
          console.log(this.form_dispatch)
          addDispatch(this.form_dispatch).then(response => {
            this.$modal.msgSuccess("下达成功");
            this.open_dispatch = false;
          });
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const mesPsUuids = row.mesPsUuid || this.ids;
      const docDts = row.docDt || this.docDts;
      const docNums = row.docNum || this.docNums;
      this.$modal.confirm('是否确认删除计划时间为"' + docDts + '",计划号为"'+docNums+'"的车间计划？','删除确认').then(function() {
        return delPs(mesPsUuids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('mes/ps/export', {
        ...this.queryParams
      }, `mes_ps.xlsx`)
    },


    /** 选择经办人 */
    showDialog_selectTaskAttentionUserName( form_dispatch ) {
      this.currentForm = form_dispatch
      // this.$refs.component_selectAttentionUser.userGroup = 'worker';
      this.$refs.component_selectAttentionUser.show();
    },
    /** 选择经办人 - 完成 */
    selectAttentionUser_done(user) {
      this.currentForm.fkAttentionUserId = user.userId
      this.currentForm.selectedAttentionUser = user.userNickNameAndId
    },

    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handleDispatch":
          this.handleDispatch(row);
          break;
        case "setDone":
          let id = row.mesPsUuid

          this.$modal.confirm( `是否确认计划号为 ${row.docNum} 的车间计划单已完成？`, '完成确认').then(function() {
            let d = {
              mesPsUuid: id,
              sysYesNoDone: row.sysYesNoDone == 'Y' ? 'N':'Y'
            }

            return updatePs(d).then(response => {
            });

          }).then(() => {
            this.$modal.msgSuccess("修改成功");
            this.getList();
          }).catch(() => {});

          break;
        default:
          break;
      }
    },
    // 显示 - 任务号
    show_task(r) {
      console.log(r)
      this.$router.push(`/mes/tasks/docNum/${r.taskDocNum}`);
    },

    /** 显示对话框：选择废品单 */
    showDialog_selectWasteForm() {
      console.log(this.form_dispatch.psDocNum)
      this.$refs.component_selectWasteForm.docNum = this.form_dispatch.psDocNum
      this.$refs.component_selectWasteForm.showDialog_selectWasteForm();
    },

    /** 选择废品单 - 完成 */
    selectWaste_done(waste) {
      this.form_dispatch.fkWasteUuid = waste.wasteUuid
      this.form_dispatch.wasteForm = `${waste.itemName}(${waste.itemNum})`

    },



  }
};
</script>
